package service;

import java.sql.SQLException;
import java.util.List;

import org.eclipse.jdt.annotation.NonNull;

import bean.User;
import dao.UserDAO;

public class UserServiceImpl implements UserService {
    private UserDAO userDAO;

    public UserServiceImpl(UserDAO userDAO) {
        this.userDAO = userDAO;
    }

    @Override
    public boolean add(@NonNull User user) throws SQLException {
        return userDAO.insert(user);
    }

    @Override
    public boolean modify(@NonNull User user) throws SQLException {
        return userDAO.update(user);
    }

    @Override
    public List<User> queryAll() throws SQLException {
        return userDAO.selectAll();
    }

    @Override
    public User query(int userId) throws SQLException {
        return userDAO.select(userId);
    }

    @Override
    public boolean remove(int userId) throws SQLException {
        return userDAO.delete(userId);
    }

}
